<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../reactBag/react.development.js"></script>
    <script src="../reactBag/react-dom.development.js"></script>
    <script src="../reactBag/babel.min.js"></script>
</head>
<body>
    <button id="btn">点击添加</button>
    <div id="app"></div>

    <script type="text/babel">

        const arr = ['吃饭','睡觉','打豆豆']
        const vDom = (
            <ul>
                
                {
                    arr.map(item=>{
                        return <li key = {item}>{item}</li>
                    })
                }    
                
            </ul>
        )
        const root = ReactDOM.createRoot(document.getElementById('app'));
        root.render(vDom)
        //给btn添加点击事件
        const oBtn = document.getElementById('btn')
            oBtn.onclick=function(){
                arr.unshift('就是你')
                const vDom = (
                    <ul>

                        {
                            arr.map(item=>{
                                return <li key = {item}>{item}</li>
                            })
                        }
                        
                    </ul>
                )
                root.render(vDom)
            }
    </script>
</body>
</html>